package com.android.fastride.view.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.fastride.R;
import com.android.fastride.contract.HelpContract;
import com.android.fastride.present.HelpPresent;
import com.peng.library.mantis.expand.data.MantisDataFragment;
import com.peng.library.mantis.hint.HintConfig;
import com.peng.library.mantis.mvp.BindPresent;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

@BindPresent(HelpPresent.class)
public class HelpFragment extends MantisDataFragment<HelpContract.PRESENT, String> implements
        HelpContract.VIEW {
    public static int FAQ = 0;
    public static int RULE_DESCRIPTION = 1;
    private static String TYPE = "type";
    // 根据类型判断加载哪个页面
    // 1.常见问题。 2.规则说明
    private int type;
    View view;
    Unbinder unbinder;

    @BindView(R.id.tv_content)
    TextView tvContent;

    public static HelpFragment newInstance(int type) {
        HelpFragment helpFragment = new HelpFragment();
        Bundle arg = new Bundle();
        arg.putInt(TYPE, type);
        helpFragment.setArguments(arg);
        return helpFragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
            Bundle savedInstanceState, HintConfig.Builder hintConfigBuilder) {
        view = inflater.inflate(R.layout.fragment_help, container, false);
        unbinder = ButterKnife.bind(this, view);
        type = getArguments().getInt(TYPE, 1);
        if (type == RULE_DESCRIPTION) {
            tvContent.setText("规则说明");
        } else {
            tvContent.setText("1.点击抢单按钮既可进行抢单。\n2.订单详情页面也可以点击立即抢单。");
        }
        return view;
    }

    @Override
    public void onReceiveData(String s) {

    }

    @Override
    public void onReceiveError(Throwable error) {

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if(unbinder != null) {
            unbinder.unbind();
            unbinder = null;
        }
    }
}
